package pl.maciejziarko.mshare.security;

import org.apache.shiro.authz.SimpleAuthorizationInfo;
import pl.maciejziarko.mshare.domain.Role;
import pl.maciejziarko.mshare.utils.Check;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Maciej Ziarko
 */
public final class MShareAuthorizationInfo extends SimpleAuthorizationInfo {

    public MShareAuthorizationInfo(List<Role> roles) {
        Check.notNull(roles, "Roles cannot be null.");

        Set<String> rolesSet = new HashSet<>();

        for (Role role : roles) {
            rolesSet.add(role.getName());
        }

        this.setRoles(rolesSet);
    }
}
